package com.chainyoung.component_tmperson.ui.adapter;

import android.support.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.chainyoung.common.utils.StringUtil;
import com.chainyoung.component_tmperson.R;
import com.chainyoung.component_tmperson.entity.DebitRepayRecord;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

public class WalletDebitRepayRecordAdapter extends BaseQuickAdapter<DebitRepayRecord, BaseViewHolder> {

    private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    private SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");

    public WalletDebitRepayRecordAdapter(@Nullable List<DebitRepayRecord> data) {
        super(R.layout.layout_item_repay_record, data);
    }


    @Override
    protected void convert(BaseViewHolder helper, DebitRepayRecord item) {
        helper.setText(R.id.tv_debit_time, sdf1.format(new Date(item.getLoans_time() * 1000)));
        helper.setText(R.id.tv_total_period, "共" + item.getTotal_period() + "期");
        helper.setText(R.id.tv_current_period, "当前第" + item.getRepayment_index() + "期");
        helper.setText(R.id.tv_principal_amount, StringUtil.subZeroAndDot(item.getPrincipal()));
        helper.setText(R.id.tv_interest_amount, StringUtil.subZeroAndDot(item.getInterests()));
        helper.setText(R.id.tv_time, sdf.format(new Date(item.getAddtime() * 1000)));
        helper.setText(R.id.tv_repay_method,item.getRepayMethodStr());
    }


}
